﻿




using System.Web;
using System.Web.Routing;
using Microsoft.Practices.Unity;
using Hotpot.Models;

namespace Hotpot.Routing
{
    public class OpenSearchConstraint : IRouteConstraint
    {
        private readonly IUnityContainer container;

        public OpenSearchConstraint(IUnityContainer container)
        {
            this.container = container;
        }

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            Site site = container.Resolve<Site>();

            if (site != null)
                return site.IncludeOpenSearch;

            return false;
        }
    }
}
